<%@page import="com.yh.vo.ZhanfengVO"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
	<head>
		<jsp:include page="/admin/head.jsp"></jsp:include>
	</head>
	<body>
		<jsp:include page="/admin/header.jsp"></jsp:include>
		<jsp:include page="/admin/left-menu.jsp"></jsp:include>
		<jsp:include page="/admin/footer.jsp"></jsp:include>

		<!--中间-->
		<section>
			<nav aria-label="breadcrumb">
				<ol class="breadcrumb">
					<li class="breadcrumb-item">管理首页</li>
					<li class="breadcrumb-item">系统中心</li>
					<li class="breadcrumb-item active">用户管理</li>
				</ol>
			</nav>

			<form class="form-inline">
				<div class="form-group mx-sm-1 mb-2">
					<label class="sr-only">新闻类别：</label>
					<select class="form-control">
						<option value="">全部</option>
					</select>
				</div>
				<div class="form-group mx-sm-1 mb-2">
					<label class="sr-only">关键字：</label>
					<input type="text" class="form-control" placeholder="搜索关键字">
				</div>
				<button type="submit" class="btn btn-primary mb-2"><i class="fa fa-search"></i></button>
				<a href="admin/user-add-form.jsp" class="btn btn-success ml-auto mr-2"><i class="fa fa-plus"></i></a>
			</form>
			<div class="ml-2 mr-2">
				<table class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th scope="col">#</th>
							<th scope="col">用户名称</th>
							<th scope="col">用户年龄</th>
							<th scope="col">用户性别</th>
							<th scope="col">用户注册时间</th>
							<th scope="col">操作</th>
						</tr>
					</thead>
					<%
					List<ZhanfengVO> list = (List<ZhanfengVO>)request.getAttribute("list");
					for(int i = 0; i < list.size(); i++){
						ZhanfengVO vo = list.get(i);
					%>
					<tbody>
						<tr>
							<th scope="row"><%=i+1 %></th>
							<td><%=vo.getZfName() %></td>
							<td><%=vo.getZfAge() %></td>
							<td><%=vo.getZfSex() %></td>
							<td><%=vo.getZfTime() %></td>
							<td>
								<div class="dropdown">
  									<button class="btn btn-outline-primary btn-block dropdown-toggle" type="button" data-toggle="dropdown">
    									操作
  									</button>
  									<div class="dropdown-menu dropdown-menu-right">
    									<a class="dropdown-item" href="admin/user-look.let?userId=<%=vo.getZfId()%>">查看</a>
    									<a class="dropdown-item" href="admin/user-update-form.let?userId=<%=vo.getZfId()%>">修改</a>
    									<a class="dropdown-item _delete" href="admin/user-delete.let?userId=<%=vo.getZfId()%>">删除</a>
  									</div>
								</div>
							</td>
						</tr>
					</tbody>
					<%} %>
				</table>
			</div>
			
			<%-- 分页 --%>
			<nav aria-label="Page navigation example">
  				<ul class="pagination justify-content-center">
    				<li class="page-item">
      					<a class="page-link" href="admin/user-page.let?index=1" aria-label="Previous">
        					<span aria-hidden="true">&laquo;</span>
      					</a>
    				</li>
    				<%
    				int pages = (int)request.getAttribute("pages");
    				int p = (int)request.getAttribute("p");
    				for(int i = 1;i<=pages;i++){
    				%>
    				<li class="page-item <%=p==i?"active":"" %>"><a class="page-link" href="admin/user-page.let?index=<%=i%>"><%=i %></a></li>
    				<%}%>
    				<%--<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(1-1)*5%>">1</a></li>
    				<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(2-1)*5%>">2</a></li>
    				<li class="page-item"><a class="page-link" href="admin/user-page.let?index=<%=(3-1)*5%>">3</a></li>
    				 --%>
    				<li class="page-item">
      					<a class="page-link" href="admin/user-page.let?index=<%=pages%>" aria-label="Next">
        					<span aria-hidden="true">&raquo;</span>
      					</a>
    				</li>
  				</ul>
			</nav>
		</section>
		
		<div class="modal fade" id="confirmDialog" tabindex="-1">
  			<div class="modal-dialog">
    			<div class="modal-content">
      				<div class="modal-header">
        				<h5 class="modal-title" id="exampleModalLabel">确认对话框</h5>
        				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
          					<span aria-hidden="true">&times;</span>
       					</button>
      				</div>
      				<div class="modal-body">
        				您确定要删除这条记录吗？
      				</div>
      				<div class="modal-footer">
        				<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        				<a href="#" class="btn btn-primary">确定</a>
      				</div>
    			</div>
  			</div>
		</div>  
		
	</body>

</html>
<script type="text/javascript">
	var confirmDialog = $("#confirmDialog");
	$("._delete").on("click",function(){
		confirmDialog.find("a:last").attr("href",$(this).attr("href"));
		confirmDialog.modal("show");
		return false;
	});
</script>